package vashion.azeroth.core.api.request;

import java.util.List;

import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;

import org.apache.commons.lang3.StringUtils;

import com.alibaba.fastjson.annotation.JSONField;

public class AddOrderRequest extends BaseRequest {

	// 订单请求

	/**
	 * api 方法：增加订单
	 * 
	 * */
	private @Setter @Getter String method = "gy.erp.trade.add";

	/**
	 * 店铺code
	 * */
	@JSONField(name = "shop_code")
	@NonNull
	private @Setter @Getter String shopCode;

	/**
	 * 物流公司code
	 * */
	@JSONField(name = "express_code")
	@NonNull
	private @Setter @Getter String expressCode;

	/**
	 * 仓库code
	 * */
	@JSONField(name = "warehouse_code")
	@NonNull
	private @Setter @Getter String warehouseCode;

	/**
	 * 会员code
	 * */
	@JSONField(name = "vip_code")
	@NonNull
	private @Setter @Getter String vipCode;

	/**
	 * 拍单时间
	 * 
	 * 例：2015-03-17 15:03:45
	 * */
	@JSONField(name = "deal_datetime")
	@NonNull
	private @Setter @Getter String dealDatetime;

	/**
	 * 发票类型 1-普通发票；2-增值发票
	 * 
	 * */
	@JSONField(name = "invoice_type")
	@NonNull
	private @Setter @Getter int invoiceType;

	/**
	 * details商品信息数组
	 * 
	 * */
	@JSONField(name = "details")
	@NonNull
	private @Setter @Getter List<Detail> details;

	/**
	 * payments支付信息数组
	 * 
	 * */
	@JSONField(name = "payments")
	@NonNull
	private @Setter @Getter List<Payment> payments;

	/**
	 * invoices发票信息数组
	 * 
	 * */
	@JSONField(name = "invoices")
	@NonNull
	private @Setter @Getter List<Invoice> invoices;

	// ------------------以下参数可为空------------------------------

	/**
	 * 订单类型code
	 * 
	 * */
	@JSONField(name = "order_type_code")
	private @Setter @Getter String orderTypeCode;

	/**
	 * 是否退款 0非退款 ，1--退款（退款中）；
	 * 
	 * */
	@JSONField(name = "refund")
	private @Setter @Getter int refund;

	/**
	 * 货到付款
	 * 
	 * */
	@JSONField(name = "cod")
	private @Setter @Getter Boolean cod;

	/**
	 * 结算方式code
	 * 
	 * */
	@JSONField(name = "order_settlement_code")
	private @Setter @Getter String orderSettlementCode;

	/**
	 * 平台单号
	 * 
	 * */
	@JSONField(name = "platform_code")
	private @Setter @Getter String platformCode;

	/**
	 * 收货人
	 * 
	 * */
	@JSONField(name = "receiver_name")
	private @Setter @Getter String receiverName;

	/**
	 * 收货地址
	 * 
	 * */
	@JSONField(name = "receiver_address")
	private @Setter @Getter String receiverAddress;

	/**
	 * 收货邮编
	 * 
	 * */
	@JSONField(name = "receiver_zip")
	private @Setter @Getter String receiverZip;

	/**
	 * 收货人电话 手机和电话必填一项
	 * 
	 * */
	@JSONField(name = "receiver_mobile")
	private @Setter @Getter String receiverMobile;

	/**
	 * 收货人电话 手机和电话必填一项
	 * 
	 * */
	@JSONField(name = "receiver_phone")
	private @Setter @Getter String receiverPhone;

	/**
	 * 收货人省份
	 * 
	 * */
	@JSONField(name = "receiver_province")
	private @Setter @Getter String receiverProvince;

	/**
	 * 收货人城市
	 * 
	 * */
	@JSONField(name = "receiver_city")
	private @Setter @Getter String receiverCity;

	/**
	 * 收货人区域
	 * 
	 * */
	@JSONField(name = "receiver_district")
	private @Setter @Getter String receiverDistrict;

	/**
	 * 标记code
	 * 
	 * */
	@JSONField(name = "tag_code")
	private @Setter @Getter String tagCode;

	/**
	 * 付款时间
	 * 
	 * */
	@JSONField(name = "pay_datetime")
	private @Setter @Getter String payDatetime;

	/**
	 * 业务员code
	 * 
	 * */
	@JSONField(name = "business_man_code")
	private @Setter @Getter String businessManCode;

	/**
	 * 物流费用
	 * 
	 * */
	@JSONField(name = "post_fee")
	private @Setter @Getter Double postFee;

	/**
	 * 到付服务费
	 * 
	 * */
	@JSONField(name = "cod_fee")
	private @Setter @Getter Double codfee;

	/**
	 * 让利金额
	 * 
	 * */
	@JSONField(name = "discount_fee")
	private @Setter @Getter Double discountFee;

	/**
	 * 预计发货日期
	 * 
	 * */
	@JSONField(name = "plan_delivery_date")
	private @Setter @Getter String planDeliveryDate;

	/**
	 * 买家留言
	 * 
	 * */
	@JSONField(name = "buyer_memo")
	private @Setter @Getter String buyerMemo;

	/**
	 * 卖家备注
	 * 
	 * */
	@JSONField(name = "seller_memo")
	private @Setter @Getter String sellerMemo;

	/**
	 * 二次备注
	 * 
	 * */
	@JSONField(name = "seller_memo_late")
	private @Setter @Getter String sellerMemoLate;

	public Boolean check() {

		if (StringUtils.isEmpty(shopCode)) {

			return false;
		}

		if (StringUtils.isEmpty(expressCode)) {

			return false;
		}

		if (StringUtils.isEmpty(warehouseCode)) {

			return false;
		}

		if (StringUtils.isEmpty(vipCode)) {

			return false;
		}

		if (StringUtils.isEmpty(dealDatetime)) {

			return false;
		}

		if (details == null || details.size() == 0) {

			return false;
		}

		if (payments == null || payments.size() == 0) {

			return false;
		}

		if (invoices == null || invoices.size() == 0) {

			return false;
		}
		return true;
	}
}
